package flow.action;

import flow.model.FlowInstanceSection;
import m.common.action.ActionMeta;
import m.common.action.VueResult;
import m.common.model.util.QueryCondition;
import m.html.VueListResult;
import m.html.element.attr.Align;
import m.html.element.attr.ButtonType;
import m.html.element.other.Param;
import m.html.list.*;
import manage.action.ManageAction;

@ActionMeta(name="flow/flowInstanceSection")
public class FlowInstanceSectionAction extends ManageAction {
	private FlowInstanceSection model;

	public VueResult myTodoList() throws Exception{
		VueListResult result=getVueListResult("待办列表",FlowInstanceSection.class,actionUrl("myTodoList"));
		result.setSubTitle("我的待办列表");
		result.addCol(toIndexColumn());
		result.addCol(toTextColumn("业务类型", "flowInstance.business.type",true));
		result.addCol(toLinkColumn("业务标题", "flowInstance.business.title",230,true,
			new ListEvent("page/base/flow/flowInfo.js",EventType.MODAL,1200)
				.addParam("business.oid","flowInstance.business.oid")
		));
		result.addCol(toTextColumn("当前环节", "flowInstance.currentSection.identity",150,true)
			.setFieldExpression("concat(#{flowInstance.currentSection.name},'(',#{flowInstance.currentSection.identity},')')"));
		result.addCol(toTextColumn("处理人", "user.realname",true));
		result.addCol(toDateTimeColumn("接收时间", "acceptDate",160,true).setSort(ListSortOrder.DESC));
		result.addCol(toTextColumn("环节", "flowSection.identity",150,true)
			.setFieldExpression("concat(#{flowSection.name},'(',#{flowSection.identity},')')"));
		result.addCol(toTextColumn("完成状态", "doneStatus",true).setAlign(Align.CENTER).setDictOption(FlowInstanceSection.class,"doneStatus"));
		result.addCol(toDateTimeColumn("完成时间", "doneDate",160,true).setSort(true));
		result.addCol(toSpaceColumn("操作",100,
			ListElement.test("record.doneStatus=='N'",
				ListButton.modal("处理", ButtonType.PRIMARY,"page/base/flow/flowInfo.js",1200, SuccessMethod.REFRESH)
					.addParam("business.oid","flowInstance.business.oid")
					.addQueryParam(Param.value("edit","true"))
			),
			ListElement.elseOther(
				ListButton.modal("流程图",ButtonType.DEFAULT,"page/base/flow/viewFlowDefine.js",800,SuccessMethod.REFRESH)
					.addParam("instanceOid","flowInstance.oid").addParam("defineOid","flowSection.flowDefine.oid")
			)
		).setFixed(Align.RIGHT));
		result.addCondition(QueryCondition.eq("user.oid", getSessionAdmin().getOid()));
		result.addCondition(QueryCondition.in("flowInstance.business.doneStatus","Y","N"));
		return result;
	}
	public FlowInstanceSection getModel() {
		return model;
	}

	public void setModel(FlowInstanceSection model) {
		this.model = model;
	}
	
}
